<template>
  <div>
      <van-row>
        <van-col span="24">
            <heads/>
        </van-col>
      </van-row>

      <van-row>
        <van-col span="2.5">
            <left/>
        </van-col>
        <van-col span="21.5">
            组织名称：<input type="text" placeholder="请输入组织名称" v-model="text" />
            <van-button color="purple" icon="search">查询</van-button> 
            <van-button color="black" icon="replay">重置</van-button> <br>
            <van-button color="blue" icon="plus" @click="add()">新增</van-button>

            <van-uploader :after-read="upload">
                <van-button color="red" icon="arrow-up">上传</van-button>
            </van-uploader>

            <van-button color="green" @click="download()" icon="down">导出</van-button> <br> <br>
            <xtree />
        </van-col>

      </van-row>
      
  </div>
</template>

<script>
import left from '../comm/left.vue'
import heads from '../comm/heads.vue'
import xtree from '../comm/xtree.vue'

import axios from '../../http/axios'
import fileDownload from "js-file-download";

export default {
    components:{
        'left':left,
        'heads':heads,
        'xtree':xtree,
    },
    data(){
        return{
            text:'',
            list:[]
        }
    },
    methods:{
        upload(file){
            let fromData = new FormData()
            fromData.append('file',file.file)
            axios('upload','post',fromData).then(res=>{
                this.$toast.fail('导入成功')
                console.log(res);
            })
        },
        download(){
            axios('download','get').then(res=>{
                this.$toast.success('导出成功')
                fileDownload(res.data,'file.xls');
                console.log(res);
            })
        }
    }
}
</script>

<style>

</style>